package com.jiantong.work.impl.dao;

import com.jiantong.common.util.UserUtil;
import com.jiantong.user.ext.LoginUser;
import com.jiantong.work.model.BeastsBreedStockMessage;
import io.terminus.common.mysql.dao.MyBatisDao;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * 数据分析 - 存栏合计统计
 * Created by mz03 on 2017/4/17.
 *
 *
 */
@Repository
public class BeastsBreedStockMessageDao extends MyBatisDao<BeastsBreedStockMessage>{

    /**
     * 根据类型和指定天数 查找最新存栏合计总和
     * 从前往后的查找
     * @param map
     * @return
     */
    public List<Long> findByType(Map<String,Object> map){


        LoginUser loginUser = UserUtil.getCurrentUser();
        List<Long> breedFactoryIds = loginUser.getBreedFactoryIds();
        map.put("breedFactoryIds",breedFactoryIds);
        return getSqlSession().selectList(sqlId("findByType"),map);
    }
    public List<Long> findByType1(Map<String,Object> map){
        return getSqlSession().selectList(sqlId("findByType"),map);
    }
    /**
     * 根据类型查询最近7天的存栏合计总和
     * @param type
     * @return
     */
    public List<Long> findByType7Day(Integer type){
        return getSqlSession().selectList(sqlId("findByType7Day"),type);
    }
}
